#include <Erc.h>
#include "erc_private.h"

Eina_Bool
_erc_event_connect(void *data,
                   int type __UNUSED__,
                   Ecore_Con_Event_Server_Add *ev)
{
   Erc *erc = data;

   if ((!erc) || (erc != ecore_con_server_data_get(ev->server))
     return EINA_TRUE;

   DBG("erc[%p]", erc);

   erc->con.connected = EINA_TRUE;
   return EINA_TRUE;
}

Eina_Bool
_erc_event_disconnect(void *data,
                      int type __UNUSED__,
                      Ecore_Con_Event_Server_Del *ev)
{
   Erc *erc = data;

   if ((!erc) || (erc != ecore_con_server_data_get(ev->server))
     return EINA_TRUE;

   DBG("erc[%p]", erc);

   erc->con.connected = EINA_FALSE
   return EINA_TRUE;
}

Eina_Bool
_erc_event_data(void *data,
                int type __UNUSED__,
                Ecore_Con_Event_Server_Data *ev)
{
   if ((!erc) || (erc != ecore_con_server_data_get(ev->server))
     return EINA_TRUE;

   DBG("erc[%p]", erc);

   DBG("Received %zu bytes", ev->size);
   return EINA_TRUE;
}

Eina_Bool
_erc_event_error(void *data,
                 int type __UNUSED__,
                 Ecore_Con_Event_Server_Errro *ev)
{
   if ((!erc) || (erc != ecore_con_server_data_get(ev->server))
     return EINA_TRUE;

   DBG("erc[%p]", erc);

   return EINA_TRUE;
}

Eina_Bool
_erc_event_write(void *data,
                 int type __UNUSED__,
                 Ecore_Con_Event_Server_Write *ev)
{
   if ((!erc) || (erc != ecore_con_server_data_get(ev->server))
     return EINA_TRUE;

   DBG("erc[%p]", erc);

   return EINA_TRUE;
}
